package com.etone.smartAudit.domain;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.Date;

/**
 * @author: sovy
 * @date: 2020-06-03 14:44:51
 * @description:
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@TableName(value = "d_admin")
public class Admin implements Serializable {

    @TableId(type = IdType.AUTO, value = "intId")
    private Integer id;

    /**
     * 账号 unique = true
     */
    @TableField(value = "vcAccount")
    private String account;

    /**
     * 密码
     */

    @TableField(value = "vcPassword")
    private String password;

    /**
     * 用户名称
     */
    @TableField(value = "vcNickName")
    private String nickName;

    /**
     * 角色id
     */
    @TableField(value = "intRoleId")
    private Integer roleId;

    /**
     * 联系方式
     */
    @TableField(value = "vcTel")
    private String tel;

    /**
     * 事务所|公司名称
     */
    @TableField(value = "vcCompanyName")
    private String companyName;

    /**
     * 事务所|公司id
     */
    @TableField(value = "intCompanyId")
    private Integer companyId;

    /**
     * 管理员所属角色
     */
    @TableField(exist = false)
    private AdminRole role;

    /**
     * 是否是超级管理员
     */
    @TableField(value = "isSuper")
    private Boolean isSuper;

    /**
     * 操作时间
     */
    @TableField(value = "dtCreateTime")
    private Date createTime;

    /**
     * 创建人
     */
    @TableField(value = "intCreateAdminId")
    private Integer createAdminId;

    /***
     * 邮箱
     */
    @TableField(value = "vcEmail")
    private String email;

    /***
     * 是否有创建文件的权限
     */
    @TableField(exist = false)
    private Boolean hasCreateFile=false;
    /**
     * 获取管理员是否是超级管理员
     *
     * @return
     */
    public boolean isAdmin() {
        return (isSuper != null && isSuper) || (role != null && role.getIsSupper());
    }
}